ig.module(
	'game.entities.base.dragme'
)
.requires(
	'impact.entity',
        'game.entities.base.entityBase'
)

.defines(function()
{
    EntityDragme = EntityEntityBase.extend(
    {
        animSheet: null,
        font: new ig.Font( 'media/04b03.font.png' ),
        draging: false,
        
        update: function()
        {
            if (ig.input.released('mouse_left'))
            {
                this.draging = false;
            }
            else if (ig.input.pressed('mouse_left') && this.isMouseOver())
            {
                var entityArray = ig.game.getEntitiesByType(EntityDragme);
                var found = false;
                for (var i = 0; i < entityArray.lenght; ++i)
                {
                    found = true;
                    break;
                }
                
                if (found == false)
                {
                    this.draging = true;
                }
            }
            
            if (this.draging == true)
            {
                this.pos.x += ig.input.mouse.x - this.lastMouseX;
                this.pos.y += ig.input.mouse.y - this.lastMouseY;                
            }
            
            this.lastMouseX = ig.input.mouse.x;
            this.lastMouseY = ig.input.mouse.y;   
            this.parent();
        },            
        
        draw: function()
        {
            this.parent();                    
        }
    });
});